refactor: limit auto-merge duplicate siblings to metaprogramming attributes#4539
Draft
raineorshine wants to merge 1 commit into
Draft
refactor: limit auto-merge duplicate siblings to metaprogramming attributes#4539raineorshine wants to merge 1 commit into
raineorshine wants to merge 1 commit into
Conversation
…ibutes Auto-merge of duplicate siblings previously fired unconditionally in moveThought, causing normal duplicate thoughts to silently disappear when moved onto the same parent (e.g. #3621). Narrow the merge gate so it only fires within metaprogramming-attribute contexts, where hierarchical merging of attribute subtrees (=children, =style, etc.) is required. Normal duplicate siblings now coexist. Update moveThought/importText/swapNote/uncategorize tests: convert merge-mechanics coverage to meta-attribute versions and add normal-duplicate coexistence tests including the #3621 regression. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#3621
Summary
Auto-merge of duplicate siblings previously fired unconditionally in the
moveThoughtreducer (drag & drop, indent/outdent, collapse/uncategorize,importText). When a thought was moved into a context that already contained a sibling with the same value, the two were merged and the source thought deleted — causing normal duplicate thoughts to silently disappear (e.g. #3621).This narrows the merge gate so it only fires within metaprogramming-attribute contexts, where hierarchical merging of attribute subtrees (
=children,=style,=pin, …) is required so a context never ends up with two of the same attribute. Normal duplicate siblings now coexist.Change
Single surgical gate change in
src/actions/moveThought.ts:isAttribute(sourceThought.value)— merges the attribute node itself when moved onto a context that already has it.destinationContext.some(isAttribute)— destination is inside a meta subtree; drives the hierarchical recursion (mergeThoughtsmoves each descendant back throughmoveThought, staying inside the meta subtree so duplicates merge all the way down).sameContext(rerank),skipMerge(swapParent), empty-thought guard (Empty thought in a series of copied thoughts is not pasted on the destination #4448).The merge machinery (
mergeThoughts.ts, action export,swapParentskipMerge,importTextcollapse trick) is otherwise unchanged.Tests
moveThought.ts— converted merge-mechanics tests to meta-attribute versions (preserving merge coverage); added aduplicate normal siblings are not mergedblock including the Duplicate thought disappears when move onto the same indentation on root or the same parent #3621 regression.importText.ts— normal top-level import now produces coexisting duplicates; added a meta-attribute import-merge test.swapNote.ts,uncategorize.ts— updated expectations to reflect coexistence.Notes
=archiveis an attribute, so archiving duplicate thoughts still merges (no regression). A stricter "normal thoughts never merge on archive" is a possible follow-up.Verification
yarn lintclean,yarn testgreen (1423 passed).